﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using LiveCharts.Wpf;
using LiveCharts;
using Separator = LiveCharts.Wpf.Separator;

namespace QuickStart_Project_01.Chart
{
    /// <summary>
    /// BarChartView.xaml 的交互逻辑
    /// </summary>
    public partial class BarChartView : UserControl
    {
        public SeriesCollection BarSeriesCollection { get; set; }
        public AxesCollection BarAxisX { get; set; }
        public AxesCollection BarAxisY { get; set; }

        public BarChartView()
        {
            InitializeComponent();

            BarSeriesCollection = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title = "2023",
                    Values = new ChartValues<double> { 10, 20, 31, 23 },
                    Fill = Brushes.Teal,
                    MaxColumnWidth = 50,
                    DataLabels = true
                },
                new ColumnSeries
                {
                    Title = "2024",
                    Values = new ChartValues<double> { 10, 50, 39, 50 },
                    Fill = Brushes.Teal,
                    MaxColumnWidth = 50,
                    DataLabels = true
                },
                new ColumnSeries
                {
                    Title = "2025",
                    Values = new ChartValues<double> { 11, 56, 42, 48 },
                    Fill = Brushes.Orange,
                    DataLabels = true
                }
            };

            BarAxisX = new AxesCollection
            {
                new Axis
                {
                    Labels = new[] { "Q1", "Q2", "Q3", "Q4", "Q5", "Q6" },
                    Separator = new Separator { Step = 1 }
                }
            };

            BarAxisY = new AxesCollection
            {
                new Axis
                {
                    LabelFormatter = value => value + "%",
                    MinValue = 0,
                    MaxValue = 100
                }
            };

            DataContext = this;
        }

    }
}
